//
//  ZDForwardCell.m
//  OCSinaWeiBo
//
//  Created by Apple on 15/11/2.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "ZDForwardCell.h"
#import "UILabel+Extension.h"

@interface ZDForwardCell ()

/**
 *  转发微博内容显示label
 */
@property (nonatomic, strong) UILabel *forwardLabel;

/**
 *  转发微博显示背景view
 */
@property (nonatomic, strong) UIView *bkgView;

@end

@implementation ZDForwardCell


- (void)prepareUI
{
    [super prepareUI];
    
    //添加子控件
    [self.contentView insertSubview:self.bkgView belowSubview:self.pictureView];
    [self.contentView addSubview:self.forwardLabel];

    //添加约束
    [_bkgView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.contentLabel.mas_bottom).offset(margin);
        make.left.right.mas_equalTo(self.contentView);
        make.bottom.mas_equalTo(self.bottomView.mas_top);
    }];
    
    [_forwardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_bkgView.mas_top).offset(margin);
        make.left.mas_equalTo(_bkgView.mas_left).offset(margin);
        make.width.mas_equalTo(ZDScreenSize.width - 2 * margin);
    }];
    
    [self.pictureView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_forwardLabel.mas_bottom).offset(margin);
        make.left.mas_equalTo(self).offset(margin);
        make.width.height.mas_equalTo(0);
    }];
    
    self.pictureViewWidthC = self.pictureView.constraints.firstObject;
    self.pictureViewHeightC = self.pictureView.constraints.lastObject;
    
}


///重写父类属性的setter方法
- (void)setStatus:(ZDStatus *)status
{
//    ZDLog(@"ZDForwardCell");
    
    [super setStatus:status];
    
    self.forwardLabel.text = [NSString stringWithFormat:@"@%@:%@", status.retweeted_status.user.name, status.retweeted_status.text];
}


#pragma mark 懒加载
- (UIView *)bkgView
{
    if (!_bkgView)
    {
        _bkgView = [[UIView alloc] init];
        
        _bkgView.backgroundColor = [UIColor colorWithWhite:0.93 alpha:1.0];
    }
    
    return _bkgView;
}

- (UILabel *)forwardLabel
{
    if (!_forwardLabel)
    {
        _forwardLabel = [[UILabel alloc] initWithFontSize:14 color:nil];
        
        _forwardLabel.numberOfLines = 0;
    }
    
    return _forwardLabel;
}

@end
